package cn.cloud.butler.uploadapi.repository;


import cn.cloud.butler.uploadapi.domain.AppVersionEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface AppversionRepository extends JpaRepository<AppVersionEntity,Long> {
    AppVersionEntity findByVerNumAndIdentify(Long vernum, String identify);

    @Query(value="select * from AppVersion where VerNum=(select MAX(VerNum) from AppVersion where Identify= ?1 )",
            nativeQuery = true)
   AppVersionEntity findNewestByIdentify(String identify);

    AppVersionEntity findByVerNum(Long vernum);

    @Query(value="select * from AppVersion where VerNum=(select MAX(VerNum) from AppVersion)",
            nativeQuery = true)
    AppVersionEntity findNewestApk();

    @Query(value="select * from AppVersion where VerNum=(select MAX(VerNum) from AppVersion where Identify = ?1)",
            nativeQuery = true)
    AppVersionEntity findNewestApkByIdentify(String identify);


}
